package util;

import java.util.List;

import model.vo.MrainfoVO;
import model.vo.ProSelCountVO;
import model.vo.StateReportVO;
import model.vo.TracontVO;

public class ViewUtil {
	public static String Tracont2List(List<TracontVO> list, String state){
		StringBuffer sb=new StringBuffer();
		sb.append("<table class='table-short1' style='width: 100%'>");
		if(list.size()!=0){
			sb.append("<colgroup>");
			sb.append("<col width='230px'/>");
			sb.append("<col/>");
			sb.append("<col width='15px'/>");
			sb.append("</colgroup>");
			sb.append("<tbody>");
			//for(NaipVO vo:list){
			for(int i=0;i<list.size();i++){
				TracontVO vo=(TracontVO)list.get(i);
					/*
					sb.append("<tr class='odd' onmouseover=ChangeBackground(this,'over'); onmouseout=ChangeBackground(this,'out');>");
					 */
					if(i%2==0){
						sb.append("<tr class='odd'>");
					}else if(i%2!=0){
						sb.append("<tr>");
					}
					sb.append("<td style='padding-left: 10px'><div class='ellipsis' style='width:100%;' title='"+vo.getRacont_nm()+"'>"+vo.getRacont_nm()+"</div></td>");
					
					if(state.equals("Y")){
						sb.append("<td><a href='#' class='button1 addMargin' onclick='return false'><span>삭제</span></a></td>");
					}else{
						sb.append("<td><a href='#' class='button' onclick=tracont2_delete('"+vo.getPro_id()+"','"+vo.getRacont_nm()+"','"+state+"')><span>삭제</span></a></td>");
					}
					
					sb.append("<td></td>");
					sb.append("</tr>");
			}
			sb.append("</tbody>");
		}else{
			sb.append("<tr class='odd'><td  class='noDataTD' colspan='3'>-컨테이너값이 없습니다-</td></tr>");
		}
		sb.append("</table>");
		return sb.toString();
	}
	public static String changeTracont1List(List<TracontVO> list, String state){
		StringBuffer sb=new StringBuffer();
		sb.append("<table class='table-short1' style='width: 100%;'>");
		if(list.size()!=0){
			sb.append("<colgroup>");
			sb.append("<col width='190px' />");
			sb.append("<col/>");
			sb.append("<col width='15px' />");
			sb.append("</colgroup>");
			sb.append("<tbody>");
			//for(NaipVO vo:list){
			for(int i=0;i<list.size();i++){
				TracontVO vo=(TracontVO)list.get(i);
					/*
					sb.append("<tr class='odd' onmouseover=ChangeBackground(this,'over'); onmouseout=ChangeBackground(this,'out');>");
					 */
					if(i%2==0){
						sb.append("<tr class='odd'>");
					}else if(i%2!=0){
						sb.append("<tr>");
					}
					sb.append("<td style='padding-left: 10px'><div class='ellipsis' style='width:100%;' title='"+vo.getRacont_nm()+"'>"+vo.getRacont_nm()+"</div></td>");
					if(state.equals("Y")){
						sb.append("<td><a href='#' class='button1' onclick='return false' style='margin:0 1px;'><span>공통</span></a><a href='#' class='button1' onclick='return false' style='margin:0 1px;'><span>삭제</span></a></td>");
					}else{
						sb.append("<td><a href='#' class='button' onclick=tracont2_insert('"+vo.getPro_id()+"','"+vo.getRainfo_id()+"','"+vo.getRacont_nm()+"','"+vo.getBase_lev1()+"','"+state+"') style='margin:0 1px;'><span>공통</span></a><a href='#' class='button' onclick=tracont1_delete('"+vo.getPro_id()+"','"+vo.getRainfo_id()+"','"+vo.getRacont_nm()+"','"+state+"') style='margin:0 1px;'><span>삭제</span></a></td>");
					}
					sb.append("<td></td>");
					sb.append("</tr>");
			}
			sb.append("</tbody>");
		}else{
			sb.append("<tr class='odd'><td  class='noDataTD' colspan='3'>-컨테이너값이 없습니다-</td></tr>");
		}
		sb.append("</table>");
		return sb.toString();
	}
	/*
	public static String createChangeConTable(List<TracontVO> list){
		System.out.println(list);
		StringBuffer sb=new StringBuffer();
		sb.append("<table class='table-long'>");
		sb.append("<colgroup>");
		sb.append("<col width='45px' />");
		sb.append("<col width='110px' />");
		sb.append("<col width='110px' />");
		sb.append("<col/>");
		sb.append("<col width='15px' />");
		sb.append("</colgroup>");
		sb.append("<tbody>");
		//for(NaipVO vo:list){
		for(int i=0;i<list.size();i++){
			TracontVO vo=(TracontVO)list.get(i);
				//sb.append("<tr class='odd' onmouseover=ChangeBackground(this,'over'); onmouseout=ChangeBackground(this,'out');>");
				if(i%2==0){
					sb.append("<tr class='odd'>");
				}else if(i%2!=0){
					sb.append("<tr>");
				}
				sb.append("<td class='col-chk'><input type='checkbox' name='checkCon' id='check${status.index+1 }' style='cursor:pointer' value='"+vo.getRainfo_id()+"|"+vo.getRacont_id()+"'></input></td>");
				sb.append("<td><div class='ellipsis' style='width:100%;' title='"+vo.getAk_type()+"'>"+vo.getAk_type()+"</div></td>");
				sb.append("<td><div class='ellipsis' style='width:100%;' title='"+vo.getAk_standard()+"'>"+vo.getAk_standard()+"</div></td>");
				sb.append("<td><div class='ellipsis' style='width:100%;' title='"+vo.getRacont_nm()+"'>"+vo.getRacont_nm()+"</div></td>");
				sb.append("<td></td>");
				sb.append("</tr>");
		}
		sb.append("</tbody>");
		sb.append("</table>");
		return sb.toString();
	}
	public static String makeTracontTableAjax(List<TracontVO> conList){
		StringBuffer sb=new StringBuffer();
		sb.append("<table class='table-short1' style='width: 300px; margin-left: 80px;'>");
		sb.append("<colgroup>");
		sb.append("<col width='80px' />");
		sb.append("<col width='80px' />");
		sb.append("<col/>");
		sb.append("<col width='15px' />");
		sb.append("</colgroup>");
		sb.append("<tbody>");
		//for(NaipVO vo:list){
		for(int i=0;i<conList.size();i++){
			TracontVO tvo=(TracontVO)conList.get(i);
			if(i%2==0){
				sb.append("<tr class='odd' onclick=tracontImfoDiv('"+tvo.getAk_id()+"','"+tvo.getRacont_id()+"')>");
			}else if(i%2!=0){
				sb.append("<tr onclick=tracontImfoDiv('"+tvo.getAk_id()+"','"+tvo.getRacont_id()+"')>");
			}
			sb.append("<td><div class='ellipsis' style='width:100%;' title='"+tvo.getAk_type()+"'>"+tvo.getAk_type()+"</div></td>");
			sb.append("<td><div class='ellipsis' style='width:100%;' title='"+tvo.getAk_standard()+"'>"+tvo.getAk_standard()+"</div></td>");
			sb.append("<td><div class='ellipsis' style='width:100%;' title='"+tvo.getRacont_nm()+"'>"+tvo.getRacont_nm()+"</div></td>");
			sb.append("<td></td>");
			sb.append("</tr>");
		}
		sb.append("</tbody>");
		sb.append("</table>");
		return sb.toString();
		/*
		sb.append("<table class='tb01' cellPadding='0' border='0' width='100%' style='table-layout:fixed;'>");
		sb.append("<colgroup>");
		sb.append("<col width='80px' />");
		sb.append("<col width='80px' />");
		sb.append("<col/>");
		sb.append("<col width='15px' />");
		sb.append("</colgroup>");
		sb.append("<tbody>");
		//for(NaipVO vo:list){
		for(int i=0;i<conList.size();i++){
			TracontVO tvo=(TracontVO)conList.get(i);
			sb.append("<tr height='35px' onclick=tracontImfoDiv('"+tvo.getAk_id()+"','"+tvo.getRacont_id()+"')  onmouseover=ChangeBackground(this,'over'); onmouseout=ChangeBackground(this,'out');>");																			
			sb.append("<td><div class='ellipsis' style='width:100%;' title='"+tvo.getAk_type()+"'>"+tvo.getAk_type()+"</div></td>");
			sb.append("<td><div class='ellipsis' style='width:100%;' title='"+tvo.getAk_standard()+"'>"+tvo.getAk_standard()+"</div></td>");
			sb.append("<td class='leftline'>");
			sb.append("<div class='ellipsis' style='width:100%;' title='"+tvo.getRacont_nm()+"'>"+tvo.getRacont_nm()+"</div>");
			sb.append("</td>");
			sb.append("<td class='rightline'></td>");
			sb.append("</tr>");
		}
		sb.append("</tbody>");
		sb.append("</table>");
		return sb.toString();
		*/
	/*
	}
	*/
	public static String noDataTable(int tdNum){
		StringBuffer sb=new StringBuffer();
		sb.append("<table class='table-short1' style='width: 300px; margin-left: 80px;'>");
		sb.append("<tr class='odd'>");
		sb.append("<td style='text-align: center; height: 35px ; vertical-align: middle; ' valign='middle' colspan='"+tdNum+"'>-컨테이너 값이 없습니다-</td>");
		sb.append("</tr>");
		sb.append("</table>");
		return sb.toString();
	}
	
	public static String changeMappingTable(List<MrainfoVO> list){
		System.out.println(list);
		StringBuffer sb=new StringBuffer();
		sb.append("<table class='table-short1' style='width: 340px; margin-right: 10px'>");
		if(list.size()!=0){
			sb.append("<colgroup>");
			sb.append("<col width='85px' />");
			sb.append("<col width='100px' />");
			sb.append("<col width='25px' />");
			sb.append("<col width='25px' />");
			sb.append("<col width='25px' />");
			sb.append("<col/>");
			sb.append("<col width='15px' />");
			sb.append("</colgroup>");
			sb.append("<tbody>");
			//for(NaipVO vo:list){
			for(int i=0;i<list.size();i++){
				MrainfoVO vo=(MrainfoVO)list.get(i);
					/*
					sb.append("<tr class='odd' onmouseover=ChangeBackground(this,'over'); onmouseout=ChangeBackground(this,'out');>");
					 */
					if(i%2==0){
						sb.append("<tr class='odd'>");
					}else if(i%2!=0){
						sb.append("<tr>");
					}
					sb.append("<td style='padding-left: 10px'><div class='ellipsis' style='width:100%;' title='"+vo.getRainfo_id()+"'>"+vo.getRainfo_id()+"</div></td>");
					sb.append("<td><div class='ellipsis' style='width:100%;' title='"+vo.getRainfo_nm()+"'>"+vo.getRainfo_nm()+"</div></td>");
					sb.append("<td>"+vo.getC_score()+"</td>");
					sb.append("<td>"+vo.getI_score()+"</td>");
					sb.append("<td>"+vo.getA_score()+"</td>");
					sb.append("<td>"+vo.getT_score()+"</td>");
					sb.append("<td></td>");
					sb.append("</tr>");
			}
			sb.append("</tbody>");
		}else{
			sb.append("<tr class='odd'><td style='text-align: center; height: 35px ; vertical-align: middle;' colspan='7' valign='middle'>-정보가 없습니다-</td></tr>");
		}
		sb.append("</table>");
		return sb.toString();
	}
	
	
	
	public static String ts_nm3ListSelectBox(List<StateReportVO> list){
		StringBuffer sb=new StringBuffer();
		//<option  value="${list.ts_nm3 }">${list.ts_nm3 }</option>
		sb.append("<select name='ts_nm3' id='ts_nm3' class='selectBox'  style='width: 92%'>");
		sb.append("<option selected='selected' value='0'>전체</option>");
		for(int i=0;i<list.size();i++){
			StateReportVO vo=(StateReportVO)list.get(i);
			sb.append("<option  value='"+vo.getTs_nm3()+"'>"+vo.getTs_nm3()+"</option>");
		}
		sb.append("</select>");
		return sb.toString();
	}
	
	
	
	//그래프 테이블
	public static String makeGraphTableAjax(String pro_nm, List<ProSelCountVO> list){
		StringBuffer sb=new StringBuffer();
		sb.append("<table id='myTable2' style='width: 100%;'>");
		sb.append("<caption>"+pro_nm+"</caption>");
		sb.append("<thead>");
		sb.append("<tr>");
		sb.append("<th></th>");
		for(int i=0;i<list.size();i++){
			ProSelCountVO vo=(ProSelCountVO)list.get(i);
			sb.append("<th>"+vo.getGun()+"</th>");
		}
		sb.append("</tr>");
		sb.append("</thead>");
		sb.append("<tbody>");
		sb.append("<tr>");
		sb.append("<th>처리개수</th>");
		for(int i=0;i<list.size();i++){
			ProSelCountVO vo=(ProSelCountVO)list.get(i);
			sb.append("<td>"+vo.getCnt1()+"</td>");
		}
		sb.append("</tr>");
		sb.append("<tr>");
		sb.append("<th>전체</th>");
		for(int i=0;i<list.size();i++){
			ProSelCountVO vo=(ProSelCountVO)list.get(i);
			sb.append("<td>"+vo.getCnt2()+"</td>");
		}
		sb.append("</tr>");
		sb.append("</tbody>");
		sb.append("</table>");
		return sb.toString();
	}
}